package ner;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.HashSet;
import java.util.Set;


public class Knowledge {

	public static final String DATA_DIR="database";
	public static Set<String> geoNames;
	public static Set<String> countriesAndCapitals;
	public static Set<String> titlesBeforePeopleNames;
	public static Set<String> postiveWords;
	public static Set<String> negativeWords;	
	public static Set<String> lookDescWords;
	public static Set<String> generalDescWords;
	
	
	
	
	
	public static void init(){
		
		
	
		try {
			
			geoNames=readDataFromFile(DATA_DIR+File.separator+"nazwy_geograficzne.txt");
			countriesAndCapitals=readDataFromFile((DATA_DIR+File.separator+"panstwa_i_stolice.txt"));
			titlesBeforePeopleNames=readDataFromFile((DATA_DIR+File.separator+"slowa_przed_nazwiskami.txt"));
			postiveWords=readDataFromFile((DATA_DIR+File.separator+"dobry.txt"));
			negativeWords=readDataFromFile((DATA_DIR+File.separator+"zly.txt"));
			lookDescWords=readDataFromFile((DATA_DIR+File.separator+"wyglad.txt"));
			generalDescWords=readDataFromFile((DATA_DIR+File.separator+"opis.txt"));
			
			
	
		} catch (IOException e) {
			e.printStackTrace();
		}
		
		
	}
	
	
	
	
	static private Set<String> readDataFromFile(String fileName)throws IOException{
		
		Set<String> data=new HashSet<String>();
		File file=new File(fileName);
		BufferedReader br=null;
		try{
			br=new BufferedReader(new FileReader(file));
			String line=null;
			while((line=br.readLine())!=null){
				if(line.startsWith("#")){
					continue;
				}
				String words[]=line.split(";|,");
				for(String w:words){
					
					String modifW=w.trim().toLowerCase();
					if(modifW.length()>1)
						data.add(modifW);
					
					
				}
				
			}
		}
		finally{
			if(br!=null)
				br.close();
			
		}
		
		return data;
		
	}

}
